package com.atlzk.renting.house.controller;

import com.atlzk.common.entity.house.FacilityEntity;
import com.atlzk.common.utils.PageUtils;
import com.atlzk.common.utils.R;
import com.atlzk.renting.house.service.FacilityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;



/**
 * 
 *
 * @author liuzekun
 * @email 2803587841@gmail.com
 * @date 2021-07-16 20:03:44
 */
@RestController
@RequestMapping("house/facility")
@CrossOrigin
public class FacilityController {
    @Autowired
    private FacilityService facilityService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    //@RequiresPermissions("house:facility:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = facilityService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    //@RequiresPermissions("house:facility:info")
    public R info(@PathVariable("id") Long id){
		FacilityEntity facility = facilityService.getById(id);

        return R.ok().put("facility", facility);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("house:facility:save")
    public R save(@RequestBody FacilityEntity facility){
		facilityService.save(facility);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //@RequiresPermissions("house:facility:update")
    public R update(@RequestBody FacilityEntity facility){
		facilityService.updateById(facility);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("house:facility:delete")
    public R delete(@RequestBody Long[] ids){
		facilityService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
